<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得结果数据</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mysql-db-name" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_db_name</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_db_name</span> &mdash; <span class="dc-title">取得结果数据</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.mysql-db-name-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mysql_db_name</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$row</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$field</code></span>
  ] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   取得 <span class="function"><a href="mysql_list_dbs.html" class="function">mysql_list_dbs()</a></span> 调用所返回的数据库名。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-db-name-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">
       <span class="function"><a href="mysql_list_dbs.html" class="function">mysql_list_dbs()</a></span> 调用所返回的结果指针。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">row</code></dt>

     <dd>

      <p class="para">
       结果集中的行号。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">field</code></dt>

     <dd>

      <p class="para">
       字段名。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.mysql-db-name-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果成功则返回数据库名，失败返回 <strong><code>FALSE</code></strong>。如果返回了 <strong><code>FALSE</code></strong>，用
   <span class="function"><a href="mysql_error.html" class="function">mysql_error()</a></span> 来判断错误的种类。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.mysql-db-name-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2125">
    <p><strong>Example #1 <span class="function"><strong>mysql_db_name()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />error_reporting</span><span style="color: #007700">(</span><span style="color: #0000BB">E_ALL</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'dbhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'username'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'password'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db_list&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_list_dbs</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$cnt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$db_list</span><span style="color: #007700">);<br />while&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$cnt</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">mysql_db_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$db_list</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.mysql-db-name-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">本扩展自 PHP 5.5.0
起已废弃，并在自 PHP 7.0.0 开始被移除。应使用 <a href="book.mysqli.html" class="link">MySQLi</a>
或 <a href="ref.pdo_mysql.html" class="link">PDO_MySQL</a> 扩展来替换之。参见
<a href="mysqlinfo.api.choosing.html" class="link">MySQL：选择 API</a> 指南以及<a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">相关 FAQ</a> 来获取更多信息。用以替代本函数的有：</p>
   <p class="para">
    <ul class="simplelist">
     <li class="member">Query: <em>SELECT DATABASE()</em></li>
    </ul>
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    为了向下兼容，可以使用下列已废弃的别名：
    <span class="function"><strong>mysql_dbname()</strong></span>
   </p>
  </p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.mysql-db-name-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mysql_list_dbs.html" class="function" rel="rdfs-seeAlso">mysql_list_dbs()</a> - 列出 MySQL 服务器中所有的数据库</span></li>
    <li class="member"><span class="function"><a href="mysql_tablename.html" class="function" rel="rdfs-seeAlso">mysql_tablename()</a> - 取得表名</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>